package com.feiyu;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Author nanshouxiao@teacher.com.cn
 * @Date 2017-10-20 10:55
 */
public class MainTest {
    public static void main(String[] args) {
        List<Map<String, String>> list = new ArrayList<>();
        list.add(getMap("1", "feiyu"));
        list.add(getMap("2", "feiyu"));
        list.add(getMap("3", "feiyu"));
        list.add(getMap("1", "feiyu123"));
        list.add(getMap("2", "feiyu123"));
        Map<String, List<Map<String, String>>> collect = list.stream().collect(Collectors.groupingBy(item -> item.get("name")));
        System.out.println(collect);
    }

    public static Map<String, String> getMap(String id, String name) {
        Map<String, String> map = new HashMap<>();
        map.put("id", id);
        map.put("name", name);
        return map;
    }
}
